import * as echarts from '../../ec-canvas/echarts';
import { Request } from "../../utils/request.js"
var util = require('../../utils/util.js');

var request = new Request()

const app = getApp();

var ec_bar = require('ec_bar.js')
var ec_pie = require('ec_pie.js')

Page({
  data: {
    ecBar: {
      onInit: ec_bar.initBar
    },
    ecPie : {
      onInit : ec_pie.initPie
    },
    studyTime: "0",
    effectiveTime:"0"
  },

  onReady() {
  },

  onShow(){
    let that = this;
    request.get(
      "getTodayInformation/" + app.globalData.openid + '/' + util.formatTimeTwo(new Date().getTime(), 'Y-M-D'),
      null,
      function(res){
        console.log(res.data.result.time)
        if(res.statusCode != 200){
          return;
        }
        
        that.setData({
          studyTime : res.data.result.time,
          effectiveTime : res.data.result.effectiveTime
        })
      },
      function(res){
        chart.setOption(getBarOption(xAxisData, stData, etData, ptData));
      }
    )
  }
});
